package com.lyj.system.controller.question;

import com.lyj.common.core.controller.BaseController;
import com.lyj.common.core.domain.R;
import com.lyj.common.core.domain.TableDataInfo;
import com.lyj.system.domain.question.dto.QuestionAddDTO;
import com.lyj.system.domain.question.dto.QuestionEditDTO;
import com.lyj.system.domain.question.dto.QuestionQueryDTO;
import com.lyj.system.domain.question.vo.QuestionDetailVO;
import com.lyj.system.service.question.QuestionService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-08-17
 * Time: 22:23
 */
@RestController
@RequestMapping("/question")
@Slf4j
/**
 * 题目管理接口
 */
public class QuestionController extends BaseController {
    @Resource(name = "questionServiceImpl")
    private QuestionService questionService;
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
        return getTableDataInfo(questionService.list(questionQueryDTO));
    }

    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toR(questionService.add(questionAddDTO));
    }

    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId) {
        return R.ok(questionService.detail(questionId));
    }

    @PutMapping("/edit")
    public R<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
        return toR(questionService.edit(questionEditDTO));
    }

    @DeleteMapping("/delete")
    public R<Void> delete(Long questionId){
        return toR(questionService.delete(questionId));
    }

}
